//
// Created by 51165 on 2025/10/22.
//
#include <stdio.h>
int main() {
    int n,m;
    scanf("%d %d",&n,&m);
    int arr1[n];
    int arr2[m];
    int arr3[n+m];

    for (int i = 0; i < n; i++) {
        scanf("%d",&arr1[i]);
    }

    for (int i = 0; i < m; i++) {
        scanf("%d",&arr2[i]);
    }

    for (int i = 0,j = 0; i< n+m; i++) {
        if (i < n) {
            arr3[i] =  arr1[i];
        }
        else {
            arr3[i] = arr2[j];
            j++;
        }
    }

    int s = n+m;
    for (int i = 0 ; i < n+m ; i++) {
        for (int j = 0 ; j < s-1;j++) {
            int temp = 0;
            if (arr3[j]>arr3[j+1]) {
                temp = arr3[j];
                arr3[j] = arr3[j+1];
                arr3[j+1] = temp;
            }
            else {
                continue;
            }
        }
        s--;
    }

    for (int i = 0 ; i < n+m; i++) {
        printf("%d ",arr3[i]);
    }

    return 0;
}